<template>
  <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
    <BasicTable @register="registerTable">
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              label: '开启',
              onClick: handleOpen.bind(null, record),
            },
          ]"
        />
      </template>
    </BasicTable>
  </PageWrapper>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BasicTable, useTable, TableAction, BasicColumn, FormSchema } from '/@/components/Table';
  import { PageWrapper } from '/@/components/Page';
  const dataSource = [
    {
      content: '个人房源评论',
      status: '0',
    },
    {
      content: '个人房源评论1',
      status: '1',
    },
  ];
  const columns: BasicColumn[] = [
    {
      title: '内容',
      dataIndex: 'content',
    },
    {
      title: '状态',
      dataIndex: 'status',
      format(value) {
        return ['关闭', '开启'][value];
      },
    },
  ];

  export default defineComponent({
    name: 'Comments',
    components: { BasicTable, PageWrapper, TableAction },
    setup() {
      const [registerTable, { reload }] = useTable({
        // api: listApi,
        dataSource: dataSource,
        columns,
        useSearchForm: false,
        bordered: true,
        actionColumn: {
          width: 150,
          title: '操作',
          dataIndex: 'action',
          slots: { customRender: 'action' },
        },
      });

      function handleOpen(record: Recordable) {
        console.log('handleOpen', record);
        reload();
      }

      return {
        registerTable,
        handleOpen,
      };
    },
  });
</script>
<style scoped lang="less">
.preview-img {
  width: 150px;
  display: flex;
  justify-content: center;
}
</style>
